<template>
    <div class="edit">
        <!-- 主体 -->
        <div class="main">
            <!-- 添加接诊医生  -->
            <Button type="primary" class="primary" @click="addDoctr">
                <Icon type="ios-search" size="14"/>添加接诊医生
            </Button>
            <div class="doctor">
                <!-- 医院 -->
                <span>{{ selectExpert.hospitalname }}</span>
                <!-- 科室 -->
                <span>{{ selectExpert.deptName }}</span>
                <!-- 医生姓名 -->
                <span>{{ selectExpert.name }}</span>
            </div>
            <!-- 选择专家 -->
            <Modal v-model="modal1" title="选择专家" :footer-hide="true" width="800">
                <div class="modelExpert">
                    <div class="searchExpertList">
                        <input type="text" placeholder="输入医生姓名、医院、科室" v-model.trim="searchName">
                        <Button type="primary" icon="ios-search" @click="searchExpert"></Button>
                    </div>
                    <Table stripe :columns="columns" :data="expertList" style='width:100%;'></Table>
                    <div class="page">
                        <Page :total="expertSize" :current='pageNo' :page-size="pageSize" show-total show-elevator @on-change="change1"/>
                    </div>
                </div>
            </Modal>
            <!-- 远程门诊类型 -->
            <div class="item">
                <div class="item-text">
                    <span style="color:red;">*&nbsp;</span>
                    <p>远程门诊类型</p>
                </div>
                <Select class="w-select" @on-change="changeSearchType" v-model="searchType">
                    <Option
                        v-for="(item,index) in searchTypeList"
                        :value="item.id"
                        :key="item.id"
                        style='text-align:center;'
                    >{{item.name}}</Option>
                </Select>
                <p style="margin-left:20px;color:#ff9966;">！请先选择专家后，再选择远程门诊类型。</p>
            </div>
            <!-- 医事服务费 -->
            <div class="item">
                <div class="item-text">
                    <span style="margin-left:6px">&nbsp; </span>
                    <p>医事服务费</p>
                </div>
                <p>{{ money }}元</p>
            </div>
            <!--  预约周期 -->
            <div class="item">
                <div class="item-text">
                    <span style="color:red;">*&nbsp;</span>
                    <p>预约周期</p>
                </div>
                <Select class="w-select" v-model="cycle">
                    <Option v-for="item in cycleList" :value="item.id" :key="item.id" style='text-align:center;'>{{item.name}}</Option>
                </Select>
            </div>
            <div class="item">
                <div class="item-text">
                    <span style="margin-left:6px">&nbsp; </span>
                    <p>排班模式</p>
                </div>
                <Button type="primary" @click="jump">普通设置</Button>
                <p style="margin-left:20px;color:#ff9966;">（当前为“分时段设置”，点击可切换排班模式）</p>
            </div>
            <!-- 列表 -->
            <div class="table">
                <p>远程门诊接诊数量</p>                 
                <Row class="tabletit">
                  <Col span="3">时间</Col>
                  <Col span="4">预约时间段</Col>
                  <Col span="2">星期一</Col>
                  <Col span="2">星期二</Col>
                  <Col span="2">星期三</Col>
                  <Col span="2">星期四</Col>
                  <Col span="2">星期五</Col>
                  <Col span="2">星期六</Col>
                  <Col span="2">星期日</Col>
                </Row>
                <div class="conborder">
                  <Row v-for="(item,index) of upList" :key="index" class="tablecon">
                    <Col span="3" >
                      <span v-if="index+1 == 1">
                        <button class="cus-btn" @click="upAdItem" size="small">+</button>上午
                      </span>
                      <span v-else>&nbsp;</span>
                    </Col>
                    <Col span="4">
                      <TimePicker
                        :open="item[8]"
                        :value="item[0]"
                        format="HH:mm"
                        type="timerange"
                        :steps="[1,5]"
                        :clearable="false"
                        :confirm="true"
                        :editable="false"
                        :disabled-hours="[0,1,2,3,4,5,6,7,13,14,15,16,17,18,19,20,21,22,23,24]"
                        @on-change="changeUpTime($event,index)"
                        @on-ok="upOk(index)"
                        class="tablecon"
                      >
                        <a href="javascript:void(0)" @click="upClick($event,index)">
                          <Icon type="ios-clock-outline"></Icon>
                          <template v-if="item[0][0] === '' || item[0][1] === ''">选择时间段</template>
                          <template v-else>{{ item[0][0]+'-'+item[0][1] }}</template>
                        </a>
                      </TimePicker>
                    </Col>
                    <Col span="2">
                      <InputNumber min="1" max="99" v-model="item[1]"></InputNumber>
                    </Col>
                    <Col span="2">
                      <InputNumber min="1" max="99" v-model="item[2]"></InputNumber>
                    </Col>
                    <Col span="2">
                      <InputNumber min="1" max="99" v-model="item[3]"></InputNumber>
                    </Col>
                    <Col span="2">
                      <InputNumber min="1" max="99" v-model="item[4]"></InputNumber>
                    </Col>
                    <Col span="2">
                      <InputNumber min="1" max="99" v-model="item[5]"></InputNumber>
                    </Col>
                    <Col span="2">
                      <InputNumber min="1" max="99" v-model="item[6]"></InputNumber>
                    </Col>
                    <Col span="2">
                      <InputNumber min="1" max="99" v-model="item[7]"></InputNumber>
                    </Col>
                    <Col span="2">
                      <button
                        v-if="index==upList.length-1 && upList.length!=1"
                        @click="rmUpItem"
                        class="cus-btn"
                        size="small"
                      >-</button>
                    </Col>
                  </Row>
                </div>
                <div class="conborder">
                  <Row v-for="(item,index) of dnList" :key="index" class="tablecon">
                    <Col span="3">
                      <span v-if="index+1 == 1">
                        <button class="cus-btn" @click="dnAdItem" size="small">+</button>下午
                      </span>
                      <span v-else>&nbsp;</span>
                    </Col>
                    <Col span="4">
                      <TimePicker
                        :open="item[8]"
                        :value="item[0]"
                        format="HH:mm"
                        type="timerange"
                        :steps="[1,5]"
                        :clearable="false"
                        :confirm="true"
                        :editable="false"
                        :disabled-hours="[0,1,2,3,4,5,6,7,8,9,10,11,12,18,19,20,21,22,23,24]"
                        @on-change="changeDnTime($event,index)"
                        @on-ok="dnOk(index)"
                      >
                        <a href="javascript:void(0)" @click="dnClick($event,index)">
                          <Icon type="ios-clock-outline"></Icon>
                          <template v-if="item[0][0] === '' || item[0][1] === ''">选择时间段</template>
                          <template v-else>{{ item[0][0]+'-'+item[0][1] }}</template>
                        </a>
                      </TimePicker>
                    </Col>
                    <Col span="2">
                      <InputNumber min="1" max="99" v-model="item[1]"></InputNumber>
                    </Col>
                    <Col span="2">
                      <InputNumber min="1" max="99" v-model="item[2]"></InputNumber>
                    </Col>
                    <Col span="2">
                      <InputNumber min="1" max="99" v-model="item[3]"></InputNumber>
                    </Col>
                    <Col span="2">
                      <InputNumber min="1" max="99" v-model="item[4]"></InputNumber>
                    </Col>
                    <Col span="2">
                      <InputNumber min="1" max="99" v-model="item[5]"></InputNumber>
                    </Col>
                    <Col span="2">
                      <InputNumber min="1" max="99" v-model="item[6]"></InputNumber>
                    </Col>
                    <Col span="2">
                      <InputNumber min="1" max="99" v-model="item[7]"></InputNumber>
                    </Col>
                    <Col span="2">
                      <button
                        v-if="index==dnList.length-1 && dnList.length!=1"
                        @click="rmDnItem"
                        class="cus-btn"
                        size="small"
                      >-</button>
                    </Col>
                  </Row>
                </div>    
                    
            </div>
            <!-- 预约备注 -->
            <div class="item">
                <div class="item-text">
                    <span style="margin-left:6px">&nbsp; </span>
                    <span>预约备注</span>
                </div>
                <Input v-model.trim="text_info" type="textarea" maxlength="80" :rows="4" placeholder="请输入备注" />
            </div>
            <!-- 保存 -->
            <div class="save">
                <Button type="primary" @click="save">
                    <Icon type="ios-checkmark" style="margin-right: 5px" />保存
                </Button>
                <Button @click="back">
                    <i class = "iconfont icon-butongyi" style="font-size:14px;margin-right:5px"></i>取消
                </Button>
            </div>
        </div>
        <Modal @on-ok="submit" v-model="subModal" title="排班确认">
          <!-- <ul style="display:inline-block;width:48%;vertical-align:middle;text-align:center;">
            <li v-for="(item,index) of upList" :key="index">{{ item[0][0]+'-'+item[0][1] }}</li>
          </ul>
          <ul style="display:inline-block;width:48%;vertical-align:middle;text-align:center;">
            <li v-for="(item,index) of dnList" :key="index">{{ item[0][0]+'-'+item[0][1] }}</li>
          </ul> -->
          <p>请确认时间段是否有误？如需更改请点击取消~</p>
        </Modal>
    </div>
</template>
<script>
import tempHeader from "@/components/tmpHeader";
import { TimePicker } from "view-design";
import api from "@/api/commonApi";
export default {
    components: {
        tempHeader,
        TimePicker
    },
    data() {
        return {
            // 门诊类型
            searchType: -1,
            searchTypeList: [],
            money: 0,
            topLength: 8,
            botLength: 8,
            //   预约周期
            cycle: 7,
            cycleList: [
                // { id: 1, name: "一天" },
                // { id: 2, name: "二天" },
                // { id: 3, name: "三天" },
                // { id: 4, name: "四天" },
                // { id: 5, name: "五天" },
                // { id: 6, name: "六天" },
                { id: 7, name: "七天" },
                { id: 8, name: "八天" },
                { id: 9, name: "九天" },
                { id: 10, name: "十天" },
                { id: 11, name: "十一天" },
                { id: 12, name: "十二天" },
                { id: 13, name: "十三天" },
                { id: 14, name: "十四天" },
                { id: 15, name: "十五天" }
            ],
            switch1: true,
            text_info: "",
            // 添加专家model
            modal1: false,
            expertNo: 1,
            expertSize: 10,
            upList: [
              [["08:00", "09:00"], null, null, null, null, null, null, null, false],
              [["09:00", "10:00"], null, null, null, null, null, null, null, false],
              [["10:00", "11:00"], null, null, null, null, null, null, null, false],
              [["11:00", "12:00"], null, null, null, null, null, null, null, false]
            ],
            dnList: [
              [["13:00", "14:00"], null, null, null, null, null, null, null, false],
              [["14:00", "15:00"], null, null, null, null, null, null, null, false],
              [["15:00", "16:00"], null, null, null, null, null, null, null, false],
              [["16:00", "17:00"], null, null, null, null, null, null, null, false]
            ],
            // 医院ID
            id: 82,
            selectExpert: {},
            expertList: [
                {
                    hospital: "蚌埠中医院",
                    deparment: "内科",
                    name: "李正兰",
                    host: "主任医师"
                }
            ],
            // 医生表头信息
            columns:[
                {
                    title:"医院名称",
                    key:"hospitalname",
                    align:"center"
                },
                {
                    title:"科室名称",
                    key:"deptName",
                    align:"center"
                },
                {
                    title:"医生名称",
                    key:"name",
                    align:"center"
                },
                {
                    title:"职称",
                    key:"titleName",
                    align:"center"
                },
                {
                    title:"选择",
                    align:"center",
                    render:(h,params) =>{
                        let row = params.row;
                        
                        return [
                            h('a',{
                                on:{
                                    click: () => {
                                        this.expert(row)
                                    }
                                }
                            },"选择")
                        ]
                    }
                }
            ],
            searchName: "",
            province: null,
            city: null,
            area: null,
            hospital: null,
            isBack: 2,
            subModal: false,
        };
    },
    created() {
        let query = this.$route.query;
        this.id = query.id ? parseInt(query.id) : null;
        this.province = query.province ? parseInt(query.province) : null;
        this.city = query.city ? parseInt(query.city) : null;
        this.area = query.area ? parseInt(query.area) : null;
        this.hospital = query.hospital ? parseInt(query.hospital) : null;
        this.selectExpert.hospitalname = query.hospitalname ? query.hospitalname : null;
        this.selectExpert.hospitalid = query.hospitalid ? parseInt(query.hospitalid) : null;
        this.selectExpert.deptName = query.deptName ? query.deptName : null;
        this.selectExpert.deptType = query.deptType ? query.deptType : null;
        this.selectExpert.name = query.name ? query.name : null;
        this.selectExpert.id = query.doctorId ? parseInt(query.doctorId) : null;
        this.selectExpert.title = query.title ? query.title : null;
        this.selectExpert.titleName = query.titleName ? query.titleName : null;
        this.searchType = query.searchType
          ? query.searchType
          : "普通门诊";
        this.money = query.money ? parseInt(query.money) : 0;
        this.cycle = query.cycle ? parseInt(query.cycle) : 1;
        this.text_info = query.text_info ? query.text_info : null;
        let breadList = [
            { path: "/index", title: "首页" },
            {
                path: "/index/operation/doctorManagement/index",
                title: "医生端运营"
            },
            {
                path: "/index/operation/remoteclinic/list",
                title: "远程门诊"
            }
        ];
        this.$emit("changeBreadList", breadList);
        this.getDetail(this.$route.query.id);
        window.document.body.addEventListener("click", this.closeTimePicker);
    },
    methods: {
      getDetail(id) {
          this.$axios.post(api.findRemoteDoctorMasterById, { id }).then(res => {
              if (res.data.code) {
                  let ret = res.data.object;
                  console.log(ret)
                    // 号源
                  ret.timesList.map((el, i) => {
                    if (el.hyDay == 1) {
                      this.upList = [];
                      return;
                    } else if (el.hyDay == 2) {
                      this.dnList = [];
                      return;
                    }
                  });
                  ret.timesList.map((el, i) => {
                    if (el.hyDay == 1) {
                      let tmpPiece = [el.timeStart, el.timeEnd];
                      if (this.upList.length <= 0) {
                        let tmpArr = [
                          tmpPiece,
                          null,
                          null,
                          null,
                          null,
                          null,
                          null,
                          null
                        ];
                        tmpArr[el.hyWeek] = el.hyNum;
                        this.upList.push(tmpArr);
                      } else {
                        let pFlag = true;
                        let tmpIndex = null;
                        let tmpArr = [
                          tmpPiece,
                          null,
                          null,
                          null,
                          null,
                          null,
                          null,
                          null
                        ];
                        this.upList.map((ele, i) => {
                          if (ele[0].toString() === tmpPiece.toString()) {
                            pFlag = false;
                            tmpIndex = i;
                          }
                        });
                        if (pFlag) {
                          tmpArr[el.hyWeek] = el.hyNum;
                          this.upList.push(tmpArr);
                        } else {
                          this.upList[tmpIndex][el.hyWeek] = el.hyNum;
                        }
                      }
                    } else if (el.hyDay == 2) {
                      let tmpPiece = [el.timeStart, el.timeEnd];
                      if (this.dnList.length <= 0) {
                        let tmpArr = [
                          tmpPiece,
                          null,
                          null,
                          null,
                          null,
                          null,
                          null,
                          null
                        ];
                        tmpArr[el.hyWeek] = el.hyNum;
                        this.dnList.push(tmpArr);
                      } else {
                        let pFlag = true;
                        let tmpIndex = null;
                        let tmpArr = [
                          tmpPiece,
                          null,
                          null,
                          null,
                          null,
                          null,
                          null,
                          null
                        ];
                        this.dnList.map((ele, i) => {
                          if (ele[0].toString() === tmpPiece.toString()) {
                            pFlag = false;
                            tmpIndex = i;
                          }
                        });
                        if (pFlag) {
                          tmpArr[el.hyWeek] = el.hyNum;
                          this.dnList.push(tmpArr);
                        } else {
                          this.dnList[tmpIndex][el.hyWeek] = el.hyNum;
                        }
                      }
                    }
                  });
                  // 远程门诊类型
                  this.searchType = ret.outpatintTypeId;
                  // 门诊周期
                  this.cycle = ret.term;
                  // 备注
                  this.text_info = ret.remarks;
                  this.money = ret.fee;
                  // 医生姓名
                  this.selectExpert.name = ret.doctorName;
                  this.selectExpert.doctorId = ret.doctorId;
                  // 医院名字
                  this.selectExpert.hospitalname = ret.hospitalName;
                  // 医院id
                  this.selectExpert.hospitalid = ret.hospitalId;
                  // 科室
                  this.selectExpert.deptName = ret.deptName;
                  this.selectExpert.deptType = ret.deptType;
                  this.selectExpert.title = ret.title;
                  this.selectExpert.titleName = ret.titleName;
                  this.id = ret.id
                  // 获取远程门诊类型
                  this.getRemoteClinic(ret.hospitalId);                  
              }
          });
        },
        addDoctr() {
            this.searchExpert();
            this.modal1 = true;
        },
        //  取消,后退 上一次
        back() {
            let pageNo = this.$route.query.pageNo;
            // function全局方法
            this.functionJS.queryNavgationTo(
                this,
                "/index/doctorOperation/remoteclinic/list",
                {
                    pageNo,
                    province: this.province,
                    city: this.city,
                    area: this.area,
                    hospital: this.hospital,
                    isBack: 2
                }
            );
        },
        // 根据选择不同的门诊类型改变不同的价格
        changeSearchType(val) {
            this.searchTypeList.forEach(item => {
                if (item.id == val) {
                    this.money = item.cost;
                }
            });
        },
        // 模态框的分页器改变
        change1(index) {
            this.expertNo = index;
            this.searchExpert();
        },
        save(){
          this.subModal = true
        },
        // 保存/新增专家
        submit() {
            let params = {};
            // 号源
            let tmpRegistertimes = [];
            this.upList.map((el, i) => {
                for (let i = 1; i <= 7; i++) {
                if (el[i] != "" && el[i] > 0) {
                    let tmpObj = {};
                    tmpObj.timeStart = el[0][0];
                    tmpObj.timeEnd = el[0][1];
                    tmpObj.hyNum = el[i];
                    tmpObj.hyDay = 1;
                    tmpObj.hyWeek = i;
                    tmpRegistertimes.push(tmpObj);
                }
                }
            });
            this.dnList.map((el, i) => {
                for (let i = 1; i <= 7; i++) {
                if (el[i] != "" && el[i] > 0) {
                    let tmpObj = {};
                    tmpObj.timeStart = el[0][0];
                    tmpObj.timeEnd = el[0][1];
                    tmpObj.hyNum = el[i];
                    tmpObj.hyDay = 2;
                    tmpObj.hyWeek = i;
                    tmpRegistertimes.push(tmpObj);
                }
                }
            });
            if (tmpRegistertimes.length <= 0) {
                this.$Message.error({
                content: "请至少有一个号源有号再保存，谢谢",
                duration: 5
                });
                return false;
            }
            // 远程门诊类型
            params.outpatintTypeId = this.searchType;
            // 门诊周期
            params.term = this.cycle;
            // 备注
            params.remarks = this.text_info;
            params.fee = this.money;
            params.deptName = this.selectExpert.deptName;
            params.deptType = this.selectExpert.deptType;
            params.hospitalName = this.selectExpert.hospitalname;
            // 医生id
            params.doctorId = this.selectExpert.id;
            params.doctorName = this.selectExpert.name;
            params.title = this.selectExpert.title;
            params.titleName = this.selectExpert.titleName;
            // 医院ID
            params.hospitalId = this.selectExpert.hospitalid;
            params.timesList = tmpRegistertimes;
            params.timeType = 2
            let url = ''
            if(this.id){
              params.id = this.id
              url = api.updateRemoteDoctorMaster
            } else {
              url = api.insertRemoteDoctorMaster
            }
            if (this.searchType == -1) {
                this.$Message.info("请选择远程门诊类型");
            } else if (this.cycle < 0) {
                this.$Message.info("请选择远程门诊周期");
            } else if (params.doctorId == "") {
                this.$Message.info("请选择专家");
            } else {
                this.$axios.post(url, params).then(res => {
                    if (res.data.code) {
                        this.$Message.info("操作成功");
                        let pageNo = this.$route.query.pageNo;
                        setTimeout(() => {
                            // function全局方法
                            this.functionJS.queryNavgationTo(
                                this,
                                "/index/doctorOperation/remoteclinic/list",
                                {
                                    pageNo,
                                    province: this.province,
                                    city: this.city,
                                    area: this.area,
                                    hospital: this.hospital,
                                    isBack: 2
                                }
                            );
                        }, 800);
                    } else {
                            let info =
                                res.data.message;
                            this.$Message.info(info);
                        }
                });
            }
        },
        // 选择专家
        expert(item) {
            this.modal1 = false;
            this.selectExpert = item;
            this.getRemoteClinic(item.hospitalid);
        },
        // 远程门诊类型
        getRemoteClinic(id) {
            this.$axios
                .post(api.findRemoteOutpatientTypeList, {
                    hospitalId: id
                })
                .then(res => {
                    if (res.data.code) {
                        let ret = res.data.object;
                        this.searchTypeList = ret;
                    }
                });
        },
        // 获取医生权限管理
        searchExpert() {
            this.$axios
                .post(api.findRemoteDoctorList, {
                    pageNo: this.expertNo,
                    pageSize: 10,
                    searchKey: this.searchName.trim(),
                    iremote: 1
                })
                .then(res => {
                    if (res.data.code) {
                        this.expertList = res.data.object.records;
                        this.expertSize = res.data.object.total;
                    }
                });
        },
        closeTimePicker() {
          this.upList.map((el, i) => {
            el[8] = false;
          });
          this.dnList.map((el, i) => {
            el[8] = false;
          });
          this.$forceUpdate();
        },
        upAdItem() {
          let time = this.upList[this.upList.length - 1][0][1].toString();
          let status = time < "12:00"; //js 里面 date类型 11:00 比 12:00 大
          if (status) {
            let sliceh = parseInt(time.slice(0, 2));
            let afterh = sliceh + 1;
            let slicem = time.slice(3);
            slicem = afterh >= 12 ? "00" : slicem;
            afterh = afterh < 10 ? "0" + afterh : afterh > 12 ? "12" : afterh;
            let tmph = afterh + ":" + slicem;
            let tmpItem = [[time, tmph], null, null, null, null, null, null, null];
            this.upList.push(tmpItem);
          } else {
            this.infoMsg("上午的结束时间不能超过12:00,请先调整时间段时间再添加");
          }
        },
        dnAdItem() {
          let time = this.dnList[this.dnList.length - 1][0][1].toString();
          let status = time < "17:00"; //js 里面 date类型 11:00 比 12:00 大
          if (status) {
            let sliceh = parseInt(time.slice(0, 2));
            let afterh = sliceh + 1;
            let slicem = time.slice(3);
            slicem = afterh >= 17 ? "00" : slicem;
            afterh = afterh < 10 ? "0" + afterh : afterh > 17 ? "17" : afterh;
            let tmph = afterh + ":" + slicem;
            let tmpItem = [[time, tmph], null, null, null, null, null, null, null];
            this.dnList.push(tmpItem);
          } else {
            this.infoMsg("下午的结束时间不能超过17:00,请先调整时间段时间再添加");
          }
        },
        rmUpItem() {
          this.upList.pop();
        },
        rmDnItem() {
          this.dnList.pop();
        },
        backTime(minTime, maxTime, startTime, endTime) {
          let min = startTime,
            max = endTime;
          let tmpMinArr = minTime.split(":");
          let tmpMaxArr = maxTime.split(":");
          let tmpStartArr = startTime.split(":");
          if (min <= minTime) {
            min = minTime;
            if (max <= minTime) {
              tmpMinArr[1] = parseInt(tmpMinArr[1]) + 5;
              tmpMinArr[0] =
                tmpMinArr[1] > 55
                  ? parseInt(tmpMinArr[0]) + 1
                  : parseInt(tmpMinArr[0]);
              tmpMinArr[0] = tmpMinArr[0] < 10 ? "0" + tmpMinArr[0] : tmpMinArr[0];
              tmpMinArr[1] = tmpMinArr[1] > 55 ? 0 : tmpMinArr[1];
              tmpMinArr[1] = tmpMinArr[1] < 10 ? "0" + tmpMinArr[1] : tmpMinArr[1];
              max = tmpMinArr[0] + ":" + tmpMinArr[1];
            }
          }
          if (max >= maxTime) {
            max = maxTime;
            if (min >= maxTime) {
              tmpMaxArr[1] = parseInt(tmpMaxArr[1]) - 5;
              tmpMaxArr[0] =
                tmpMaxArr[1] < 0
                  ? parseInt(tmpMaxArr[0]) - 1
                  : parseInt(tmpMaxArr[0]);
              tmpMaxArr[0] = tmpMaxArr[0] < 10 ? "0" + tmpMaxArr[0] : tmpMaxArr[0];
              tmpMaxArr[1] = tmpMaxArr[1] < 0 ? 55 : tmpMaxArr[1];
              tmpMaxArr[1] = tmpMaxArr[1] < 10 ? "0" + tmpMaxArr[1] : tmpMaxArr[1];
              min = tmpMaxArr[0] + ":" + tmpMaxArr[1];
            }
          }
          if (min == max) {
            let minute1 = parseInt(tmpStartArr[1]) + 5;
            tmpStartArr[0] =
              minute1 > 55
                ? parseInt(tmpStartArr[0]) + 1
                : parseInt(tmpStartArr[0]);
            tmpStartArr[0] =
              tmpStartArr[0] < 10 ? "0" + tmpStartArr[0] : tmpStartArr[0];
            minute1 = minute1 < 10 ? "0" + minute1 : minute1 > 55 ? "00" : minute1;
            max = tmpStartArr[0] + ":" + minute1;
          }
          return [min, max];
        },
        changeUpTime(time, index) {
          if (index > 0) {
            //非第一行
            if (index < this.upList.length - 1) {
              //中间的
              let prev = this.upList[index - 1][0][1]; //最低时间
              let next = this.upList[index + 1][0][0]; //最高时间
              time = this.backTime(prev, next, time[0], time[1]);
            } else {
              //最后一行
              let prev = this.upList[index - 1][0][1]; //最小时间
              let next = "12:00";
              time = this.backTime(prev, next, time[0], time[1]);
            }
          } else {
            //第一行
            if (this.upList.length > 1) {
              //多行第一行
              let nextTime = this.upList[index + 1][0][0]; //最高时间
              let prev = "08:00";
              time = this.backTime(prev, nextTime, time[0], time[1]);
            } else {
              //就剩一行
              let prev = "08:00";
              let next = "12:00";
              time = this.backTime(prev, next, time[0], time[1]);
            }
          }
          this.upList[index][0] = time;
          this.$forceUpdate();
        },
        upClick(e, index) {
          e.stopPropagation();
          this.closeTimePicker();
          this.upList[index][8] = true;
          this.$forceUpdate();
        },
        upOk(index) {
          this.upList[index][8] = false;
          this.$forceUpdate();
        },
        // 跳转到分时段设置
        jump() {
          this.functionJS.queryNavgationTo(
            this,
            "/index/doctorOperation/remoteclinic/add",
            {
              id: this.id,
              province: this.province,
              city: this.city,
              area: this.area,
              hospital: this.hospital,
              isBack: 2,
              deptType: this.selectExpert.deptType,
              hospitalname: this.selectExpert.hospitalname,
              hospitalid: this.selectExpert.hospitalid,
              deptName: this.selectExpert.deptName,
              name: this.selectExpert.name,
              doctorId: this.selectExpert.doctorId,
              title: this.selectExpert.title,
              titleName: this.selectExpert.titleName,
              searchType: this.searchType,
              money: this.money,
              cycle: this.cycle,
              text_info: this.text_info,
            }
          );
        }
    },
    beforeDestroy() {
      window.document.body.removeEventListener("click", this.closeTimePicker);
    }
};
</script>
<style lang="less" scoped>
.edit {
    width: 100%;
    padding: 10px;
    margin: 0 auto;
    background: #fff;
    .main {
        width: 80%;
        margin: 15px auto;
        .doctor {
            width: 100%;
            display: flex;
            height: 40px;
            flex-direction: row;
            align-items: center;
            margin: 10px 0;
            span {
                margin-right: 20px;
                font-size: 20px;
            }
        }
        .item {
            display: flex;
            flex-direction: row;
            align-items: center;
            margin: 10px 0;
            .item-text {
                display: flex;
                flex-direction: row;
                align-items: center;
                width: 130px;
            }
            .w-select {
                width: 150px;
            }
        }
        .table {
            width: 100%;
            display: flex;
            flex-direction: column;
            margin: 10px 0;
            p {
                text-align: center;
                margin: 10px 0;
            }
            .tabletit {
                width: 100%;
                height: 40px;
                line-height: 40px;
                border: 1px solid #ddd;
                background: #f8f8f9;
                text-align: center;
            }
            .conborder{
              border: 1px solid #ddd;
              border-top: none;
            }
            .tablecon {
              text-align: center;
              margin-top: 10px;
            }
            .tablecon:last-child{
              margin-bottom: 10px;
            }
            .tablecon:hover {
                background: #ebf7ff;
            }
            .nodata {
                width: calc(100% - 1px);
                line-height: 40px;
                background: #fff;
                border: 1px solid #ddd;
                border-top: none;
                text-align: center;
            }
            .cus-btn {
              vertical-align: middle;
              width: 30px;
              height: 30px;
              line-height: 30px;
              color: #ffffff;
              font-size: 30px;
              border: 0;
              border-radius: 50%;
              background: #5362e1;
              &:focus {
                border: 0;
                outline: none;
              }
            }
        }
        .text {
            width: 100%;
            display: flex;
            flex-direction: row;
            span {
                display: inline-block;
                width: 100px;
            }
        }
        .save {
            display: flex;
            flex-direction: row;
            align-items: center;
            width: 200px;
            margin: 10px auto;
            justify-content: space-around;
        }
    }
}
.modelExpert {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    .total {
        text-align: center;
        margin: 10px 0;
    }
    .modelExpert_list {
        width: 100%;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-around;
        cursor: pointer;
        span {
            width: 25%;
            text-align: center;
            user-select: none;
        }
    }
    .searchExpertList {
        width: 100%;
        margin-bottom: 20px;
        input {
            width: 40%;
            background: #fff;
            border: none;
            outline: none;
            text-indent: 10px;
            line-height: 30px;
            border: 1px solid #ddd;
            border-radius: 4px;
        }
    }
    .page{
      text-align: center;
      margin: 20px 0;
    }
}
</style>

